import groovy.json.JsonSlurper

pipeline{
    agent {
        node {
            label 'master'
        }
    }
    stages{
      stage('http') {
          steps {
            script {
              def toJson = {
                input ->
                groovy.json.JsonOutput.toJson(input)
            }
            def body = [
                status: "DOWN"
            ]
            def creds = "admin/admin"
            def unregister_url= "http://172.17.5.245:8082/v1/rest/all?category=rest&dironly=false"
            String auth = creds.bytes.encodeBase64().toString()
            response = httpRequest consoleLogResponseBody: true, contentType: 'APPLICATION_JSON', httpMode: 'GET',
            requestBody: toJson(body), url: unregister_url, customHeaders: [[name: 'Authorization', value: "Basic $auth"]], validResponseCodes: '200'
          }
          }
          
      }
      
    }
    
}